package com.gdpu.controller;

import com.gdpu.api.CommonResult;
import com.gdpu.service.impl.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:weiming
 * @Date:2021/6/12
 */
@Api(tags = "文件上传")
@RestController
@RequestMapping("/oss")
public class FileUploadController {

    @Autowired
    private OssService ossService;

    /**
     * Oss对象文件上传
     * @param file
     * @return
     */
    @ApiOperation("阿里云Oss文件上传")
    @PostMapping("/upload")
    public CommonResult minioUpload(@RequestParam("file") MultipartFile file){
        String s = ossService.minioUpload(file);
        Map map = new HashMap(1);
        map.put("imgUrl",s);
        return CommonResult.success(map);
    }
}
